<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * @property int $id
 * @property string $openid
 * @property int $rsh_id
 * @property string $images
 * @property string $content
 * @property int $score
 * @property boolean $status
 * @property string $updated_at
 * @property string $created_at
 */
class RoomSendEva extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'room_send_eva';

    /**
     * @var array
     */
    protected $fillable = ['openid', 'images', 'content', 'created_at'];

    /**
     * Indicates if the model should be timestamped.
     *
     * @var bool
     */
    public $timestamps = false;

    /**
     * 新增记录
     * @param $data
     * @return bool
     */
    public function add($data)
    {
        $data['create_at'] = $data['updated_at'] = date('Y-m-d H:i:s');
        $data['images'] = json_encode($data['images'], JSON_UNESCAPED_UNICODE);
        try {
            return self::create($data);
        } catch (\Exception $exception) {
            return $exception->getMessage();
        }
    }
}
